<%@page import="cs236369.hw5.InitListener"%>
<%@ page language="java" contentType="text/html; charset=windows-1255"
    pageEncoding="windows-1255"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
</head>
<body>
<%@ page import="cs236369.hw5.InitListener" %>
<%@ page import="cs236369.hw5.DBConnection" %>
<%@ page import="cs236369.hw5.Skill" %>
<%@ page import="java.util.ArrayList" %>

<%
	String admin = (String)session.getAttribute("admin");
	if(admin == null) { // user is not an admin
		response.sendRedirect(request.getContextPath() + InitListener.welcomePage);
		return;
	}
	ArrayList<Skill> skills = DBConnection.getSkills(false);
%>
<div class="text">
	<p class="subtitle">Enable \ Disable existing skills</p>
	<table id="adminTable" class="adminTable">
		<tr class="title"><td>skill id</td><td>skill</td><td>is available</td><td>inverse availability</td></tr>
		<%
			int row = 1;
			String isAvailable;
			for(Skill skill : skills) {
				out.print("<tr class=\"data\">");
				out.print("<td>" + skill.getId() + "</td>");
				out.print("<td>" + skill.getSkill() + "</td>");
				isAvailable = skill.isAvailable() == true ? "yes" : "no";
				out.print("<td id=\"isAvailable" + row + "\">" + isAvailable + "</td>");
				out.println("<td><input type=\"button\" class=\"regularButton\" value=\"inverse\" id=\"inverse" + row +
						"\" onclick=\"inverseSkill(" + row + ", " + skill.getId() + ")\"></input></td></tr>");
				row++;
			}
		%>
	</table>
	<p class="subtitle">Add new skill</p>
		new skill: <input type="text" id="skillName" placeholder="enter new skill name here"></input><br />
		<input type="button" class="regularButton" value="add new skill" onclick="addSkill()"></input>
</div>
</body>
</html>